package jdbc;

import java.sql.*;

public class Select {
    public static void main(String[] args) throws SQLException {
        String url = "jdbc:mysql://127.0.0.1:3306/linyujie?useUnicode=true&amp;characterEncoding=utf-8";
        String username = "root";
        String password = "123456";
        Connection con = null;
        Statement s = null;//声明；陈述，叙述；报表，清单   switch语句 分支语句 开关语句
        ResultSet rs = null;//结果集对象
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection(url,username,password);
            s = con.createStatement();
            rs = s.executeQuery("select * from user");
            while(rs.next()){
                System.out.println(rs.getInt("id")+" "+rs.getString("username")+" "+rs.getString("password"));
            }

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        con.close();
        s.close();
        rs.close();
    }

}
